﻿using System.Linq;
using ExtendedMvc.Tests.Model;
using ExtendedMvc.Tests.Model.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExtendedMvc.Tests {


	/// <summary>
	///This is a test class for UnorderedListTest and is intended
	///to contain all UnorderedListTest Unit Tests
	///</summary>
	[TestClass()]
	public class UnorderedListTest {

		private static DummyDataSource database;
		private static ModelViewPage<Dummy> view;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext { get; set; }

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		[ClassInitialize()]
		public static void MyClassInitialize(TestContext testContext) {
			database = new DummyDataSource();
			var dummy = database.Dummies.All().First();
			view = MvcMockHelpers.FakeViewPage("Index", dummy);
		}

		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup() {
		//}
		//
		//Use TestInitialize to run code before running each test
		[TestInitialize()]
		public void MyTestInitialize() {
			view.ViewContext.ViewData.ModelState.Clear();
		}

		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup() {
		//}
		//
		#endregion

		/// <summary>
		///A test for UnorderedList Constructor
		///</summary>
		[TestMethod()]
		public void UnorderedList_NoParameters() {
			// Arrange
			var expectedOutput = string.Format(@"<ul></ul>");

			// Act
			var unorderedList = view.Html.UnorderedList();
			var output = unorderedList.ToString();

			// Assert
			Assert.AreEqual<string>(expectedOutput, output);
		}

		/// <summary>
		///A test for UnorderedList Constructor
		///</summary>
		[TestMethod()]
		public void UnorderedList_WithItems() {
			// Arrange
			var items = new string[] { "Item1", "Item2" };
			var expectedOutput = string.Format(@"<ul><li>{0}</li><li>{1}</li></ul>", items[0], items[1]);

			// Act
			var unorderedList = view.Html.UnorderedList(items);
			var output = unorderedList.ToString();

			// Assert
			Assert.AreEqual<string>(expectedOutput, output);
		}
	}
}
